using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.role
{
[System.Serializable]
public  class GiftDetail :   cfg.EditorReadWriter 
 {

    public int giftLv ;
     public System.Collections.Generic.List<cfg.fight.AttrValue> giftAttr  = new System.Collections.Generic.List<cfg.fight.AttrValue>();
     public string giftAttrTxt  = "";
     public cfg.role.EGiftType giftType ;
     public int col ;
     public int levelsum ;
     public string giftUpTxt  = "";
     public cfg.condition.Currency giftUpCost  = new cfg.condition.Currency();
     public int giftToAwake ;
     


    public const int TYPE_ID = 1708092241;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(9);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(giftLv);  
         os.WriteSize(Tag.LIST | (2 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_fight_AttrValue(giftAttr,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.STRING | (3 << Tag.TAG_SHIFT));  os.WriteString(giftAttrTxt);  
         os.WriteSize(Tag.INT | (4 << Tag.TAG_SHIFT));  os.WriteInt((int)giftType);  
         os.WriteSize(Tag.INT | (5 << Tag.TAG_SHIFT));  os.WriteInt(col);  
         os.WriteSize(Tag.INT | (6 << Tag.TAG_SHIFT));  os.WriteInt(levelsum);  
         os.WriteSize(Tag.STRING | (7 << Tag.TAG_SHIFT));  os.WriteString(giftUpTxt);  
         os.WriteSize(Tag.BEAN | (8 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_condition_Currency(giftUpCost,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (9 << Tag.TAG_SHIFT));  os.WriteInt(giftToAwake);  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   giftLv = os.ReadInt(); break;  
             case (Tag.LIST | (2 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); giftAttr = cfg.Extensions.unmarshal_compatible_list_cfg_fight_AttrValue(os); os = _oldOs; break; }   
             case (Tag.STRING | (3 << Tag.TAG_SHIFT)):   giftAttrTxt = os.ReadString(); break;  
             case (Tag.INT | (4 << Tag.TAG_SHIFT)):   giftType = (cfg.role.EGiftType)(os.ReadInt()); break;  
             case (Tag.INT | (5 << Tag.TAG_SHIFT)):   col = os.ReadInt(); break;  
             case (Tag.INT | (6 << Tag.TAG_SHIFT)):   levelsum = os.ReadInt(); break;  
             case (Tag.STRING | (7 << Tag.TAG_SHIFT)):   giftUpTxt = os.ReadString(); break;  
             case (Tag.BEAN | (8 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); giftUpCost = cfg.Extensions.unmarshal_compatible_cfg_condition_Currency(os); os = _oldOs; break; }   
             case (Tag.INT | (9 << Tag.TAG_SHIFT)):   giftToAwake = os.ReadInt(); break;  
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "GiftDetail");
        ele.WriteStartElement("giftLv"); ele.WriteAttributeString("id", "1"); ele.WriteInt(giftLv); ele.WriteEndElement();
         ele.WriteStartElement("giftAttr"); ele.WriteAttributeString("id", "2"); cfg.Extensions.xml_marshal_list_cfg_fight_AttrValue(giftAttr,ele); ele.WriteEndElement();
         ele.WriteStartElement("giftAttrTxt"); ele.WriteAttributeString("id", "3"); ele.WriteString2(giftAttrTxt); ele.WriteEndElement();
         ele.WriteStartElement("giftType"); ele.WriteAttributeString("id", "4"); ele.WriteEnum(giftType); ele.WriteEndElement();
         ele.WriteStartElement("col"); ele.WriteAttributeString("id", "5"); ele.WriteInt(col); ele.WriteEndElement();
         ele.WriteStartElement("levelsum"); ele.WriteAttributeString("id", "6"); ele.WriteInt(levelsum); ele.WriteEndElement();
         ele.WriteStartElement("giftUpTxt"); ele.WriteAttributeString("id", "7"); ele.WriteString2(giftUpTxt); ele.WriteEndElement();
         ele.WriteStartElement("giftUpCost"); ele.WriteAttributeString("id", "8"); cfg.Extensions.xml_marshal_cfg_condition_Currency(giftUpCost,ele); ele.WriteEndElement();
         ele.WriteStartElement("giftToAwake"); ele.WriteAttributeString("id", "9"); ele.WriteInt(giftToAwake); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  giftLv = ele.ReadInt(); break; 
                 case 2:  giftAttr = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrValue(ele); break; 
                 case 3:  giftAttrTxt = ele.ReadString2(); break; 
                 case 4:  giftType = ele.ReadEnum<cfg.role.EGiftType>(); break; 
                 case 5:  col = ele.ReadInt(); break; 
                 case 6:  levelsum = ele.ReadInt(); break; 
                 case 7:  giftUpTxt = ele.ReadString2(); break; 
                 case 8:  giftUpCost = cfg.Extensions.xml_unmarshal_cfg_condition_Currency(ele); break; 
                 case 9:  giftToAwake = ele.ReadInt(); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "gift_lv":  giftLv = ele.ReadInt(); break; 
                 case "gift_attr":  giftAttr = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrValue(ele); break; 
                 case "gift_attr_txt":  giftAttrTxt = ele.ReadString2(); break; 
                 case "gift_type":  giftType = ele.ReadEnum<cfg.role.EGiftType>(); break; 
                 case "col":  col = ele.ReadInt(); break; 
                 case "levelsum":  levelsum = ele.ReadInt(); break; 
                 case "gift_up_txt":  giftUpTxt = ele.ReadString2(); break; 
                 case "gift_up_cost":  giftUpCost = cfg.Extensions.xml_unmarshal_cfg_condition_Currency(ele); break; 
                 case "gift_to_awake":  giftToAwake = ele.ReadInt(); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
